//////////////////////////////////////////
//
//	FlexInc. 2011
//	http://www.loziosecchi.it/flex_inc
//	http://twitter.com/loziosecchi
//
//////////////////////////////////////////

package flexInc.spark.effects
{
	import flash.geom.Point;
	import flash.utils.ByteArray;
	
	import mx.effects.IEffectInstance;
	
	import spark.effects.AnimateTransitionShader;
	
	/**
	 *  The CrossFade effect uses Pixel Bender, 
	 *  which is not supported for AIR mobile applications.
	 */
	[DiscouragedForProfile("mobileDevice")]
	
	/**
	 * The Corona effect performs a bitmap transition effect by creating a
	 * <i>circular aura</i> between the first and second bitmaps.
	 *
	 * @see spark.effects.AnimateTransitionShader
	 * @see spark.effects.AnimateTransitionShader#shaderByteCode
	 *  
	 *  @langversion 3.0
	 *  @playerversion Flash 10
	 *  @playerversion AIR 1.5
	 *  @productversion Flex 4
	 */
	public class Corona extends AnimateTransitionShader
	{
		[Embed(source="Corona.pbj", mimeType="application/octet-stream")]
		private static var CoronaShaderClass:Class;
		private static var coronaCrossFadeShaderCode:ByteArray = new CoronaShaderClass();

		/**
		 *  The center of the corona; if the <i>x</i> or <i>y</i> values are greater
		 *  than the bitmap width, they will be positioned inside the <i>width</i> and
		 *  <i>height</i> values accordingly.
		 *
		 *  @default Point(0, 0)
		 *  
		 *  @langversion 3.0
		 *  @playerversion Flash 10
		 *  @playerversion AIR 1.5
		 *  @productversion Flex 4
		 */
		public var center:Point = new Point(0, 0);
		
		/**
		 *  Constructor. 
		 *
		 *  @param target The Object to animate with this effect.  
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10
		 *  @playerversion AIR 1.5
		 *  @productversion Flex 4
		 */
		public function Corona(target:Object=null)
		{
			super(target);
			
			shaderByteCode = coronaCrossFadeShaderCode;
		}
		
		/**
		 *  @private
		 */
		override protected function initInstance(instance:IEffectInstance):void
		{			
			var properties:Object = new Object();
			properties.centerX = center.x;			
			properties.centerY = center.y;			
			shaderProperties = properties;
			
			super.initInstance(instance);
		}
	}
}